package com.hzlx.boms.service.impl;

import java.util.List;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.hzlx.boms.mapper.BomsMapper;
import com.hzlx.boms.domain.Boms;
import com.hzlx.boms.service.IBomsService;

/**
 * BOM清单Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-01
 */
@Service
public class BomsServiceImpl implements IBomsService 
{
    @Autowired
    private BomsMapper bomsMapper;
    @Resource
    private RedisTemplate<String, Object> redisTemplateObject;
    String KEY = "base-data-service:boms";
    /**
     * 查询BOM清单
     * 
     * @param bomId BOM清单主键
     * @return BOM清单
     */
    @Override
    public Boms selectBomsByBomId(Long bomId)
    {
        return bomsMapper.selectBomsByBomId(bomId);
    }

    /**
     * 查询BOM清单列表
     * 
     * @param boms BOM清单
     * @return BOM清单
     */
    @Override
    public List<Boms> selectBomsList(Boms boms)
    {
        List<Boms> list = bomsMapper.selectBomsList(boms);
        redisTemplateObject.opsForValue().set(KEY,list);
        return list;
    }

    @Override
    public List<Boms> selectBomsListByProductId(Boms boms) {
        return bomsMapper.selectBomsListByProductId(boms);
    }

    /**
     * 新增BOM清单
     * 
     * @param boms BOM清单
     * @return 结果
     */
    @Override
    public int insertBoms(Boms boms)
    {
        return bomsMapper.insertBoms(boms);
    }

    /**
     * 修改BOM清单
     * 
     * @param boms BOM清单
     * @return 结果
     */
    @Override
    public int updateBoms(Boms boms)
    {
        return bomsMapper.updateBoms(boms);
    }

    /**
     * 批量删除BOM清单
     * 
     * @param bomIds 需要删除的BOM清单主键
     * @return 结果
     */
    @Override
    public int deleteBomsByBomIds(Long[] bomIds)
    {
        return bomsMapper.deleteBomsByBomIds(bomIds);
    }

    /**
     * 删除BOM清单信息
     * 
     * @param bomId BOM清单主键
     * @return 结果
     */
    @Override
    public int deleteBomsByBomId(Long bomId)
    {
        return bomsMapper.deleteBomsByBomId(bomId);
    }

    @Override
    public Boms selectByProductId(Long productId) {
        return bomsMapper.selectByProductId(productId);
    }
}
